package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

/**
 * @Author atguigu-mqx
 * @Description TODO
 * @Date 2023/5/23 15:34
 * @Version 1.0
 */
@Controller
public class OrderController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    /**
     * 订单结算页
     * @param model
     * @return
     */
    @GetMapping("trade.html")
    public String trade(Model model){
        //  需要存储 detailArrayList totalNum totalAmount tradeNo
//        model.addAttribute("detailArrayList",detailArrayList);
//        model.addAttribute("totalNum",totalNum);
//        model.addAttribute("totalAmount",totalAmount);
//        model.addAttribute("tradeNo",tradeNo);
        //  远程获取数据
        Result<Map> result = orderFeignClient.trade();
        //  存储数据
        model.addAllAttributes(result.getData());
        //  返回订单结算页面.
        return "order/trade";
    }

    //  http://order.gmall.com/myOrder.html

    /**
     * 查看我的订单。
     * @return
     */
    @GetMapping("myOrder.html")
    public String myOrder(){
        //  查看我的订单. 页面渲染的数据是异步查询渲染的！
        return "order/myOrder";
    }
}
